package com.springboot.controller;


import com.springboot.model.MedicineListForm;
import com.springboot.service.AssistantSeeMedicineListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;

@Controller
public class AssistantSeeMedicineList {
    @Autowired
    AssistantSeeMedicineListService assistantSeeMedicineListService;
    /**
     * 助理查看药单
     */
    @CrossOrigin
    @RequestMapping(value = "/getMedicineList")
    public @ResponseBody
    ArrayList<MedicineListForm> assistantSeeMedicineList(@RequestParam("patientId") Integer patientId)
    {
        System.out.println("查看药品清单");
        try{
            ArrayList<MedicineListForm> medicineListForms=new ArrayList<>();
            medicineListForms=assistantSeeMedicineListService.getAssistantSeeMedicineList(patientId);
            int count=medicineListForms.size();
            System.out.println("共有药品单"+count);
            return medicineListForms;
        }
        catch (Exception e)
        {
            return null;
        }
    }

}
